package com.jyw.business.ast.service.impl;

import java.util.List;

import com.jyw.business.ast.domain.vo.web.AllocateAstVo;
import com.jyw.business.ast.domain.vo.web.BorrowAstVo;
import com.jyw.business.ast.domain.vo.web.DisposeAstVo;
import com.jyw.business.ast.domain.vo.web.TransferAstVo;
import com.jyw.system.utils.ConversionUtil;
import org.springframework.stereotype.Service;
import com.jyw.business.ast.mapper.AstDealRelationMapper;
import com.jyw.business.ast.domain.AstDealRelation;
import com.jyw.business.ast.service.IAstDealRelationService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.util.ObjectUtils;

import javax.annotation.Resource;

/**
 * 资产-操作关系Service业务层处理
 * 
 * @author system
 * @date 2023-10-19
 */
@Service
public class AstDealRelationServiceImpl extends ServiceImpl<AstDealRelationMapper,AstDealRelation> implements IAstDealRelationService
{
    @Resource
    private AstDealRelationMapper astDealRelationMapper;

    /**
     * 查询资产-操作关系
     * 
     * @param id 资产-操作关系主键
     * @return 资产-操作关系
     */
    @Override
    public AstDealRelation selectAstDealRelationById(Long id)
    {
        return astDealRelationMapper.selectAstDealRelationById(id);
    }

    /**
     * 查询资产-操作关系列表
     * 
     * @param astDealRelation 资产-操作关系
     * @return 资产-操作关系
     */
    @Override
    public List<AstDealRelation> selectAstDealRelationList(AstDealRelation astDealRelation)
    {
        return astDealRelationMapper.selectAstDealRelationList(astDealRelation);
    }

    /**
     * 新增资产-操作关系
     * 
     * @param astDealRelation 资产-操作关系
     * @return 结果
     */
    @Override
    public int insertAstDealRelation(AstDealRelation astDealRelation)
    {
        return astDealRelationMapper.insertAstDealRelation(astDealRelation);
    }

    /**
     * 修改资产-操作关系
     * 
     * @param astDealRelation 资产-操作关系
     * @return 结果
     */
    @Override
    public int updateAstDealRelation(AstDealRelation astDealRelation)
    {
        return astDealRelationMapper.updateAstDealRelation(astDealRelation);
    }

    /**
     * 批量删除资产-操作关系
     * 
     * @param ids 需要删除的资产-操作关系主键
     * @return 结果
     */
    @Override
    public int deleteAstDealRelationByIds(Long[] ids)
    {
        return astDealRelationMapper.deleteAstDealRelationByIds(ids);
    }

    /**
     * 删除资产-操作关系信息
     * 
     * @param id 资产-操作关系主键
     * @return 结果
     */
    @Override
    public int deleteAstDealRelationById(Long id)
    {
        return astDealRelationMapper.deleteAstDealRelationById(id);
    }

    @Override
    public List<AllocateAstVo> allocateRelation(Long id) {
        return ConversionUtil.conversionList(astDealRelationMapper.allocateRelation(id), AllocateAstVo.class);
    }

    @Override
    public boolean canRevoke(AstDealRelation astDealRelation) {
        Integer count = astDealRelationMapper.revokeCount(astDealRelation);
        return ObjectUtils.isEmpty(count) || count ==0;
    }

    @Override
    public List<TransferAstVo> transferRelation(Long id) {
        return ConversionUtil.conversionList(astDealRelationMapper.transferRelation(id), TransferAstVo.class);
    }

    @Override
    public List<BorrowAstVo> borrowRelation(Long id) {
        return ConversionUtil.conversionList(astDealRelationMapper.borrowRelation(id),BorrowAstVo.class);
    }

    @Override
    public List<DisposeAstVo> disposeRelation(Long id) {
        return ConversionUtil.conversionList(astDealRelationMapper.disposeRelation(id),DisposeAstVo.class);
    }
}
